package com.flong.gui;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
 
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
 
public class TestJDialog {
 
    public static void main(String[] args) {
 
        final MyFrameDialog frame = new MyFrameDialog();
        JButton button = new JButton("确定");
        frame.add(button, BorderLayout.SOUTH);
        button.addActionListener(new ActionListener() {
 
            @Override
            public void actionPerformed(ActionEvent arg0) {
                JDialog dialog = new JDialog(frame, "Dialog", false);
                dialog.setSize(300, 200);
                dialog.setAlwaysOnTop(false);
                dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
                dialog.setVisible(true);
            }
        });
    }
 
}
 
@SuppressWarnings("all")
class MyFrameDialog extends JFrame {
    public MyFrameDialog() {
        setTitle("Frame");
        setAlwaysOnTop(false);
        setVisible(true);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setSize(300, 200);
    }
}